<template>
	<view class="cooperation_container">
		<view class="cooperation_box">
			<view class="cooperation_input_box">
				<view class="input_title">
					联系人
				</view>
				<view class="">
					<u-input v-model="contactsValue" placeholder="请输入联系人姓名"
						placeholder-style="font-size: 28rpx;font-weight: 400;color: #666666;" :border="false"
						:clearable="false" />
				</view>
			</view>

			<view class="cooperation_input_box">
				<view class="input_title">
					联系电话
				</view>
				<view class="">
					<u-input v-model="phoneValue" placeholder="请输入联系电话"
						placeholder-style="font-size: 28rpx;font-weight: 400;color: #666666;" maxlength="11"
						:border="false" :clearable="false" />
				</view>
			</view>

			<view class="cooperation_input_box">
				<view class="input_title">
					联系地址
				</view>
				<view class="">
					<u-input v-model="addressValue" placeholder="请输入联系地址"
						placeholder-style="font-size: 28rpx;font-weight: 400;color: #666666;" :border="false"
						:clearable="false" />
				</view>
			</view>

			<view class="cooperation_input_box">
				<view class="input_title">
					备注
				</view>
				<view class="">
					<u-input v-model="remarkValue" placeholder="请输入备注"
						placeholder-style="font-size: 28rpx;font-weight: 400;color: #666666;" :border="false"
						:clearable="false" />
				</view>
			</view>

			<view class="cooperation_btn_box" @click="handlerSubmit">
				提交
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				contactsValue: '',
				phoneValue: '',
				addressValue: '',
				remarkValue: '',
			}
		},
		onShow() {
			
		},
		methods: {
			// 提交接口
			addCoo() {
				this.$request('/api/addCooperationFront', {
					name: this.contactsValue,
					phone: this.phoneValue,
					address: this.addressValue,
					remark: this.remarkValue,
				}, 'POST').then(res => {
					if (res.code == 1) {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						setTimeout(() => {
							uni.switchTab({
								url: '/pages/my/my'
							})
						}, 1500)
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
						return
					}
				})
			},

			// 提交
			handlerSubmit() {
				if (this.contactsValue == '') {
					uni.showToast({
						title: '请输入联系人姓名',
						icon: 'none'
					})
					return
				} else if (this.phoneValue == '') {
					uni.showToast({
						title: '请输入联系电话',
						icon: 'none'
					})
					return
				} else if (this.addressValue == '') {
					uni.showToast({
						title: '联系地址',
						icon: 'none'
					})
					return
				}
				this.addCoo()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cooperation_container {
		padding: 16rpx 20rpx 0;

		.cooperation_box {
			border-radius: 16rpx;
			background: #FFFFFF;
			padding: 14rpx 42rpx 134rpx;

			.cooperation_input_box {
				display: flex;
				align-items: center;
				border-bottom: 1px solid #F0F0F0;
				padding: 38rpx 0 24rpx;

				.input_title {
					width: 160rpx;
					font-size: 32rpx;
					font-weight: 400;
					color: #000;
				}
			}

			.cooperation_btn_box {
				width: 100%;
				height: 70rpx;
				border-radius: 60rpx;
				background: #4F96FF;
				font-size: 32rpx;
				font-weight: 500;
				line-height: 70rpx;
				text-align: center;
				color: #fff;
				margin-top: 369rpx;
			}
		}
	}
</style>